Home

Computer science

'

\ufeffAmazon uses small, Roomba-shaped robots, called "Drives". They deliver large stacks of products to human workers by following set paths around the warehouse.
The warehouse can be represented in the form of a cartesian plane, where robots are located at integral points of the form (x, \ufeffy). \ufeffWhen a product is to be delivered to some point (i, \ufeffj, \ufeffthe nearest robot is sought and chosen. Thus if a robot is surrounded by other robots nearby, it will seldom be chosen for work. More formally, a robot is said to be idle if it has a robot located above, below, left, and right of it. \ufeffIt is guaranteed that no two robots are at the same location.
Given the locations of n robots, find the number of idle robots.
Example
The x and y coordinates are given as two arrays, with the coordinates aligned by index: x = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3]
and y = [1, 2, 3, 1, 2, 3, 5, 1, 2, 3 
].
'

Answer